package com.opennews.openplatform.util;

import org.apache.flink.shaded.jackson2.org.yaml.snakeyaml.Yaml;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;

public class YamlConfigLoader {
    public static Map<String, Object> loadYamlConfig(String filename) {
        InputStream inputStream = YamlConfigLoader.class.getClassLoader().getResourceAsStream(filename);
        Yaml yaml = new Yaml();

        // Parse YAML into a Map
        return yaml.load(new InputStreamReader(inputStream));
    }

    public static Map<String, Object> loadYamlConfig() {
        return loadYamlConfig("application.yml");
    }
}